<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="entity.ImageItem" %>
<%@ page import="util.ItemHelper" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.net.URLEncoder"%>
<%!
	public String getNavHref(int offset, int number, String tag)
	{
	    if(tag != null){
	        return "?number=" + number + "&offset=" + offset + "&tag=" + tag;
	    }
	    else
	    { 
	        return "?number=" + number + "&offset=" + offset;
	    }
	}
%>
<% 
    //parse params
	String soffset = request.getParameter("offset");
	String snumber = request.getParameter("number");
	String tag = request.getParameter("tag");
	int offset = 0;
	int number = 7;
	if(soffset != null)
	{
	    try{
	    offset = Integer.parseInt(soffset);
	    }
	    catch(NumberFormatException e){;}
	}
	if(snumber != null)
	{
	    try{
	        number = Integer.parseInt(snumber);
	        }
	        catch(NumberFormatException e){;}
	}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
		<link rel='stylesheet' type='text/css' href='stylesheets/main.css' />
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				$("#ladderpets").load("ladder_table.jsp?htmlid=ladderpets");
				$("#ladderuser").load("ladder_user_table.jsp?htmlid=ladderuser");
				$("#ladderall").load("ladder_table.jsp?htmlid=ladderall&tag=pets");
				document.getElementById('ladderall_sel').value = 'pets';
				$("#ladderall_sel").change(function(){
					the_url = "ladder_table.jsp?htmlid=ladderall";
					val = $("#ladderall_sel").val();
					if(val != '')
						the_url += "&tag="+val;
					$("#ladderall").load(the_url);
				});
			});
		</script>
		<title>The Ladder</title>
	</head>
	<body>
		<a href="battle.jsp" id="backlink">Back to Battle</a>
		<div id='title'>The Ladder Page</div>
		<div id="columns">
			<div class="right column">
		    	<div class='ladder-title'>User Rankings</div>
		        <div id="ladderuser"></div>
		    </div>
		    <div class="center column">
		    	<div class='ladder-title'>Rankings in </div>
		        <select id="ladderall_sel">
		            <option value="cat">Cats</option>
		            <option value="dog">Dogs</option>
		            <option value="pets">Pets</option>
		            <option value="bird">Birds</option>
		            <option value="human">Humans</option>
		            <option value="wildlife">Wildlife</option>
		        </select>
		        <div id="ladderall"></div>
		    </div>
		    <div class="left column">
		    	<div class='ladder-title'>Overall Rankings</div>
		        <div id="ladderpets"></div>
		    </div>
		</div>
	</body>
</html>